import java.util.ArrayList;
import java.util.List;
import java.util.Random;
//一副新牌
public class CardDemo {
    final String[] suit={"♥","♦","♣","♠"};

    public List<Card> buycard(){
        List<Card> cards=new ArrayList<>();
        for (int i=0;i<4;i++){
            for (int j=0;j<13;j++){
                Card card=new Card(suit[i],j);
                cards.add(card);
            }
        }
        System.out.println(cards);
        return cards;
    }
    //洗牌
public void shuffle(List<Card> cards){
    Random random=new Random();
    for (int i=cards.size()-1;i>0;i--){
       int change=random.nextInt(i);
       //交换i位置与change位置的牌
       Card tmp=cards.get(i);
       cards.set(i,cards.get(change));
       cards.set(change,tmp);
    }
    System.out.println(cards);
}
    //三人轮流拿5张牌
    public void getCard(List<Card> cards){
        List<Card> L1=new ArrayList<>();
        List<Card> L2=new ArrayList<>();
        List<Card> L3=new ArrayList<>();
        List<List<Card>> list=new ArrayList<>();
        list.add(L1);
        list.add(L2);
        list.add(L3);
        for(int j=0;j<5;j++){
            for (int i=0;i<3;i++){
                Card card=cards.remove(0);
                list.get(i).add(card);
            }
        }
        System.out.println("第一个人拿牌");
        System.out.println(L1);
        System.out.println("第二个人拿牌");
        System.out.println(L2);
        System.out.println("第三个人拿牌");
        System.out.println(L3);
    }

}
